package com.yysjyr.logisticssystem.settings.service.impl;

import com.yysjyr.logisticssystem.settings.entity.User;
import com.yysjyr.logisticssystem.settings.mapper.UserMapper;
import com.yysjyr.logisticssystem.settings.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * @author: 吃货大人
     * @date: 2023/10/5
     * @time : 19:05
     * @param username 账号
     * @return : User 用户对象
     * @description: 根据账号查询用户
     */
    @Override
    public User queryUserByUsername(String username){
        return userMapper.selectUserByUsername(username);
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/5
     * @time : 19:15
     * @param user 新增的用户信息
     * @return : int 影响的行数
     * @description: 保存新增用户信息
     */
    @Override
    public int saveCreateUserByUser(User user){
        return userMapper.insertUserByUser(user);
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/24
     * @time : 22:44
     * @param username
     * @return : 用户id
     * @description: 根据用户名查询用户id
     */
    @Override
    public String queryUserIdByUsername(String username){
        return userMapper.selectUserIdByUsername(username);
    }

}
